//
//  BSOptionAndDeviceInfoView.m
//  SuoSiApp
//
//  Created by zhang on 16/4/11.
//  Copyright © 2016年 Ym. All rights reserved.
//

#import "BSOptionAndDeviceInfoView.h"

@implementation BSOptionAndDeviceInfoView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];

    if (self) {
        [self addSubview1];
    }
    return self;
}
- (void)addSubview1{

    NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:@"(注: *号为必填项目) "];
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(4,1)];

    
    

    
    //    我的信息
    //    self.myInfoLB = [[UILabel alloc]initWithFrame:CGRectMake(kMartin20, Y , kMartin100, 43)];
    self.infoLB = [[UILabel alloc]initWithFrame:CGRectMake(kMartin10, 0 , kScreenWidth / 2 , 43)];
    
    self.infoLB.text = @"选项设置与设备信息";
    //    self.myInfoLB.attributedText = str;
    self.infoLB.font = [UIFont systemFontOfSize:20];
    
    if (kScreenWidth < 370) {
        self.infoLB.font = [UIFont systemFontOfSize:16];

    }
    
    //    [self addSubview:_myInfoLB];
    [self.scrollView addSubview:_infoLB];
    //    提示
    self.noteLB = [[UILabel alloc]initWithFrame:CGRectMake(self.infoLB.right, self.infoLB.top + kMartin10, kScreenWidth - self.infoLB.width, self.infoLB.height - kMartin20)];
    self.noteLB.attributedText = str;
    [self.scrollView addSubview:_noteLB];
    
//    数据文件上传
    CGFloat Y = self.infoLB.bottom;

    self.dataPassWifiLB = [self getLableWithFrameY:Y text:@" 数据文件上传"];
    [self getLableWithFrameY:Y + 44 text:@" 设备信号弱提示音"];
    [self getLableWithFrameY:Y + 44 * 2 text:@" 设备电量低提示音"];
    [self getLableWithFrameY:Y + 44 * 3 text:@" 设备断开提示音"];
    [self getLableWithFrameY:Y + 44 * 4 text:@" 设备脱落提示音"];
//    [self getLableWithFrameY:Y + 44 * 5 text:@"GPS定位"];
   self.GPSLB = [self makeLableWithFrameY:Y + 44 * 5 text:@" GPS定位 *  建议开启"];
    self.GPSLB.width  =self.dataPassWifiLB.width;
    


    
//    循环创建6个 UISwitch
    _wifiLB = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - kMartin80 - kMartin100, self.dataPassWifiLB.top, kMartin100 + kMartin20, 44)];
    
    
    
    
    [self.scrollView addSubview:_wifiLB];
    
    for (int i = 1; i < 7; i++) {
        UISwitch *switchBT = [[UISwitch alloc]initWithFrame:CGRectMake(kScreenWidth - kMartin60, self.dataPassWifiLB.top + 6 + 44 *(i - 1), kMartin40, kMartin15)];
        switchBT.tag = i;
        switchBT.onTintColor = BSBTGreen;
        [self.scrollView addSubview:switchBT];
    }
    
//    离线登陆
    self.offLineLB = [[UILabel alloc]initWithFrame:CGRectMake(0, self.GPSLB.bottom + 6, kScreenWidth, 44)];
    self.offLineLB.text = @" 离线数据";
    self.offLineLB.font = [UIFont systemFontOfSize:20];
    self.offLineLB.backgroundColor = BSWhite;
    [self.scrollView addSubview:_offLineLB];
    
//  离线登陆方式
    self.offLineBT = BSButton;
    
    self.offLineBT.frame = CGRectMake(kScrenWidth - 200, self.offLineLB.top, 180, self.offLineLB.height);
    [self.offLineBT setTitle:@"请选择存储时间" forState:(UIControlStateNormal)];

    [self.offLineBT setTitleColor:BSGray forState:(UIControlStateNormal)];
    
    self.offLineBT.titleLabel.textAlignment = NSTextAlignmentLeft;
    [self.scrollView addSubview:_offLineBT];
    
    UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(self.offLineBT.right - kMartin5, self.offLineBT.top + 12, kScrenWidth-self.offLineBT.right, self.offLineBT.height/2)];
    imageView1.image = [UIImage imageNamed:@"sz_10.png"];
    [self.scrollView addSubview:imageView1];
    
//    设备信息
    self.deviceInfoLB = [[UILabel alloc]initWithFrame:CGRectMake(0, self.offLineLB.bottom + 1, kScrenWidth, 44)];
    self.deviceInfoLB.text = @" 设备信息";
    self.deviceInfoLB.backgroundColor = BSWhite;

    self.deviceInfoLB.font = [UIFont systemFontOfSize:20];
    [self.scrollView addSubview:_deviceInfoLB];
    
//  选择设备信息

    self.deviceInfoBT = BSButton;
    
    self.deviceInfoBT.frame = CGRectMake(kScrenWidth - 200, self.deviceInfoLB.top, 180, self.deviceInfoLB.height);
    [self.deviceInfoBT setTitle:@"查看设备信息" forState:(UIControlStateNormal)];
    self.deviceInfoBT.titleLabel.textAlignment = NSTextAlignmentLeft;
    [self.deviceInfoBT setTitleColor:BSGray forState:(UIControlStateNormal)];
    [self.scrollView addSubview:_deviceInfoBT];
    
    UIImageView *imageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(self.offLineBT.right-kMartin5, self.deviceInfoBT.top + 12, kScrenWidth-self.offLineBT.right, self.offLineBT.height/2)];
    imageView2.image = [UIImage imageNamed:@"sz_10.png"];
    [self.scrollView addSubview:imageView2];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (UILabel *)getLableWithFrameY:(CGFloat)Y text:(NSString *)text{
    
    CGRect frame = CGRectMake(0, Y, kScreenWidth , 43);
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.text = text;
    lable.font = [UIFont systemFontOfSize:20];
    lable.backgroundColor = BSWhite;
    [self.scrollView addSubview:lable];
    return lable;
}

@end
